package cn.cdutetc.library.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 通知类型枚举
 */
@Getter
@AllArgsConstructor
public enum NotificationTypeEnum {

    SYSTEM(1, "系统通知"),
    BORROW(2, "借阅提醒"),
    RETURN(3, "还书提醒"),
    OVERDUE(4, "逾期提醒"),
    FINE(5, "罚款通知");

    private final Integer code;
    private final String desc;

    /**
     * 根据code获取枚举
     */
    public static NotificationTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (NotificationTypeEnum typeEnum : NotificationTypeEnum.values()) {
            if (typeEnum.getCode().equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }
}